![]() |
SndStartFilePlay |
||||
Header: | Sound.h | Carbon status: | Unsupported | |
Initiates a play from disk.
OSErr SndStartFilePlay ( SndChannelPtr chan, SInt16 fRefNum, SInt16 resNum, SInt32 bufferSize, void *theBuffer, AudioSelectionPtr theSelection, FilePlayCompletionUPP theCompletion, Boolean async );
A pointer to a valid sound channel. You can pass NULL instead of a pointer to a sound channel if you want the Sound Manager to internally allocate a sound channel in your application’s heap zone.
The file reference number of the AIFF or AIFF-C file to play. To play a sound resource rather than a sound file, this field should be 0.
The resource ID number of a sound resource to play. To play a sound file rather than a sound resource, this field should be 0.
The number of bytes of memory that the Sound Manager is to use for input buffering while reading in sound data. For SndStartFilePlay to execute successfully on the slowest Macintosh computers, use a buffer of at least 20,480 bytes. You can pass the value 0 to instruct the Sound Manager to allocate a buffer of the default size.
A pointer to a buffer that the Sound Manager should use for input buffering while reading in sound data. If this parameter is NULL, the Sound Manager allocates two buffers, each half the size of the value specified in the bufferSize parameter. If this parameter is not NULL, the buffer should be a nonrelocatable block of size bufferSize.
A pointer to an audio selection structure that specifies which portion of a sound should be played. You can pass NULL to specify that the Sound Manager should play the entire sound.
A pointer to a completion function that the Sound Manager calls when the sound is finished playing. You can pass NULL to specify that the Sound Manager should not execute a completion function. This field is useful only for asynchronous play. For information on the format of a completion function, see FilePlayCompletionProcPtr.
A Boolean value that indicates whether the sound should be played asynchronously (TRUE) or synchronously (FALSE). You can play sound asynchronously only if you allocate your own sound channel (using SndNewChannel). If you pass NULL in the chan parameter and TRUE for this parameter, the SndStartFilePlay function returns the badChannel result code.
A result code.
The SndStartFilePlay function begins a continuous play from disk on a sound channel. The chan parameter is a pointer to the sound channel. If chan is not NULL, it is used as a valid channel. If chan is NULL, an internally allocated sound channel is used for play from disk. This internally allocated sound channel is not passed back to you. Because SndPauseFilePlay and SndStopFilePlay require a sound-channel pointer, you must allocate your own channel if you wish to use those functions.
The sounds you wish to play can be stored either in a file or in an 'snd ' resource. If you are playing a file, then fRefNum should be the file reference number of the file to be played and the parameter resNum should be set to 0. If you are playing an 'snd ' resource, then fRefNum should be set to 0 and resNum should be the resource ID number (not the file reference number) of the resource to play.
The SndStartFilePlay function might not play 'snd ' resources from disk correctly. In particular, the function will not execute correctly if any resource in the resource file containing the 'snd ' resource you wish to play has been changed through a call to the WriteResource function and you have not updated the resource file using the UpdateResFile function. To avoid this and other problems, you should use the SndStartFilePlay function to play only sound files.
Because the SndStartFilePlay function moves memory, you should not call it at interrupt time.
Not supported in Carbon. Not available in Carbon.
You should instead use QuickTime to play sound files. Open a sound file as a QuickTime movie and play the movie back. This approach supports more audio formats (like wav and mp3) than this call supported.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)